<!DOCtype html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Medier</title>
<link rel="stylesheet" type="text/css" href="../CSS/CSS.css" />
<link rel="stylesheet" type="text/css" href="../CSS/header.css" />
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
if (!window.jQuery) {
    document.write('<script src="../Javascript/jQuery.js"><\/script>');
}
</script>
<script src="../Javascript/Popups.js"></script>
<script>
	function Back(){
        window.history.back();
    }
</script>
</head>
<body>
<?php include_once 'admin_check.php'?>
<?php include_once 'database.php' ?>
<?php include_once 'header.php' ?>

<div id='page_content'>
	<h1>Ændre medie navn:</h1>
	<?php
		include_once('session_start.php');
		include_once('get_message.php');
		
	?>    
	<form action="edit_media_db.php?action=create" method="post"> 
		<table border="1" id="create_media_table">   
	        <tr>
	        	<td>Opret nye medie:</td>
			</tr>
	        <tr>
	        	<td>
	            	<input type="text" name="MediaName[]" maxlength="20" />
				</td>
	 		</tr> 
	        <tr>
	        	<td>       
				    <input type="submit" class="submit" value="Opret medie" />
				</td>
			</tr>           
		</table>
	</form>
	
    <form action="edit_media_db.php?action=edit" method="post" id="genre_form">
        <table border="1" id="media">
        <?php
            $query = "SELECT * FROM media"; 
            $stmt = $db->query($query);     
            
            while($result=$stmt->fetch_assoc()){
                echo '<tr id="media_'.$result["MediaId"].'"> 
                            <td>
                                <input type="hidden"  id="media_'.$result["MediaId"].'_id"  name="MediaId[]" value="'.$result["MediaId"].'">
                                <input type="text"  id="media_'.$result["MediaId"].'_name" name="MediaName[]" value="'.$result["MediaName"].'">
                                </td>
                            <td>
                                <a href="edit_media_db.php?action=delete&id='.$result["MediaId"].'" class="delete" cfm_href="edit_media_db.php?action=delete&id='.$result["MediaId"].'">Slet</a>
                            </td>
                        </tr>';
                }
            if($stmt->num_rows>0){
                echo '<tr>
                        <td>
                            <input type="submit" class="submit" value="Rediger medier">
                        </td>
                    </tr>';
            }                                   
                    
        ?>
        </table>
    </form>
</div>
<?php
    include_once('footer.php');
    ?>
</body>
</html>